<?php
/* 
* @Author: LDF QQ 47121862
* @Date:   2014-06-13 09:23:16
* @Last Modified by:   LDF QQ 47121862
* @Last Modified time: 2014-06-13 11:10:41
*/
class ConfigControl extends AuthControl{
	//链接首页
	function index(){
		$page=new Page(M('config')->count());
		$this->config=M('config')->limit($page->limit())->order('cfid DESC')->all();
		$this->page=$page->show();
		$this->display();
	}
	// 添加
	function add(){
		if( !Q('name') || !Q('title') || !Q('val') ){
			echo 0;die;
		}
		$id=M('config')->add($_POST);
		echo $id?1:0;die;
	}
	// 删除
	function del(){
		$cfid=Q('cfid',0,'intval');
		$id=M('config')->del($cfid);
		echo $id?1:0;die;
	}
	//ajax
	function _ajax(){
		$lid=Q('lid',0,'intval');
		$val=Q('val',null,'');
		$name=Q('name');
		$data=array('cfid'=>$lid,$name=>$val);
		$id=M('config')->save($data);
		echo $id?1:0;
		die;
	}
	//更新缓存ajax
	function updateCache(){
		echo 0;die;
	}
}
